package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CNotebookReadDao;
import com.party.core.dao.write.commune.CNotebookWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CNotebook;
import com.party.core.service.commune.ICNotebookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party
 * @description: 笔记本
 * @author: Hua Qunhao
 * @create: 2019-12-26 10:21
 **/
@Service
public class CNotebookService implements ICNotebookService {
    @Autowired
    private CNotebookWriteDao notebookWriteDao;
    @Autowired
    private CNotebookReadDao notebookReadDao;

    @Override
    public String insert(CNotebook cNotebook) {
        BaseModel.preInsert(cNotebook);
        boolean result = notebookWriteDao.insert(cNotebook);
        if (result) {
            return cNotebook.getId();
        }
        return null;
    }

    @Override
    public boolean update(CNotebook cNotebook) {
        cNotebook.setUpdateDate(new Date());
        return notebookWriteDao.update(cNotebook);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return notebookWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CNotebook get(String id) {
        return notebookReadDao.get(id);
    }

    @Override
    public List<CNotebook> listPage(CNotebook cNotebook, Page page) {
        return notebookReadDao.listPage(cNotebook,page);
    }

    @Override
    public List<CNotebook> list(CNotebook cNotebook) {
        return notebookReadDao.listPage(cNotebook,null);
    }

    @Override
    public List<CNotebook> batchList(Set<String> ids, CNotebook cNotebook, Page page) {
        return null;
    }

    @Override
    public List<CNotebook> webListPage(Map<String, Object> params, Page page) {
        return notebookReadDao.webListPage(params,page);
    }

    @Override
    public Integer getCMaterialCount(String notebookTypeId, String notebookId) {
        return notebookReadDao.getCMaterialCount(notebookTypeId,notebookId);
    }
}
